package com.chaodriod.common.fragment;

import android.os.Bundle;
import android.support.annotation.CallSuper;
import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by 72byte on 2018/3/13.
 */
abstract public class BaseFragment extends Fragment {

    protected View mRootView;

    //获取布局
    @LayoutRes
    protected abstract int getLayoutId();

    @CallSuper
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        if (mRootView == null) {
            mRootView = inflater.inflate(getLayoutId(), container, false);
        }
        return mRootView;
    }

    public View findViewById(@IdRes int id) {
        return mRootView.findViewById(id);
    }

}